//
//  SNOrganizationCell.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/16.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNOrganizationCell.h"
@interface SNOrganizationCell()

@property (weak, nonatomic) IBOutlet UIView *bgView;

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *bigTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;

@end
@implementation SNOrganizationCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.bgView.layer.cornerRadius = 4;
    self.bgView.layer.masksToBounds = YES;
//
//    self.bgView.layer.shadowColor = HexRGB(0xdddddd).CGColor;//shadowColor阴影颜色
//    self.bgView.layer.shadowOffset = CGSizeMake(1,1);//shadowOffset阴影偏移,x向右偏移4，y向下偏移4，默认(0, -3),这个跟shadowRadius配合使用
//    self.bgView.layer.shadowOpacity = 1.0;//阴影透明度，默认0
//    self.bgView.layer.shadowRadius = 4;//阴影半径，默认3
    
    self.bgView.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"aaaa"].CGImage);
    

}
-(void)setModel:(SNOrganizationResult *)model{
    _model = model;
    // "230000|黑龙江省;230400|鹤岗市;230421|萝北县;null;凤翔镇曙光村西北侧"
    
    self.bigTitleLabel.text = [model.fullName isEqualToString:@""] ? @"未知":model.fullName;
    
    if ([model.legalName isEqualToString:@""] || model.legalName == nil) {
        model.legalName = @"未知";
    }
    if ([model.legalPhone isEqualToString:@""] || model.legalPhone == nil) {
        model.legalPhone = @"未知";
    }
    self.infoLabel.text = [NSString stringWithFormat:@"%@ %@",model.legalName,model.legalPhone];
    
//    NSArray<NSString *> * strings = [model.REGADDR componentsSeparatedByString:@";"];
//    
//    NSMutableString * strM = [NSMutableString string];
    
    
//    NSMutableString * strM = [NSMutableString string];
//    NSString *searchText = model.REGADDR;
//    NSRange range = [searchText rangeOfString:@"[\u4E00-\u9FFF]+" options:NSRegularExpressionSearch];
//    while (range.location != NSNotFound) {
//        NSLog(@"range ：%@", [searchText substringWithRange:range]);
//        
//        [strM appendString:[NSString stringWithFormat:@"%@ ",[searchText substringWithRange:range]]];
//        searchText =  [searchText substringFromIndex:range.location+range.length];
//        range = [searchText rangeOfString:@"[\u4E00-\u9FFF]+" options:NSRegularExpressionSearch];
//    }

    
    
    self.addressLabel.text = model.filteredAddress;
    
    
    
    
//    for(int i = 0; i < strings.count; i++) {
//        
//        if (i==strings.count-1) {
//            NSString * string = [strings[i] componentsSeparatedByString:@"|"].lastObject;
//            
//            if (![string isEqualToString:@"null"]) {
//                [strM appendFormat:@"%@",string];
//            }
//            
//            
//            
//        }else{
//            
//            NSString * string = [strings[i] componentsSeparatedByString:@"|"].lastObject;
//            if (![string isEqualToString:@"null"]) {
//                [strM appendFormat:@"%@ ",string];
//            }
//            
//        }
//    }
//    
//    
//    self.addressLabel.text = strM;
    
    
    switch (model.organType.integerValue) {
        case 1:
            self.iconImageView.image = [UIImage imageNamed:@"合作社"];
            break;
        case 2:
            self.iconImageView.image = [UIImage imageNamed:@"农场"];
            break;
        case 3:
            self.iconImageView.image = [UIImage imageNamed:@"大户"];
            break;
        default:
            break;
    }
    
//    self.iconImageView.image = [UIImage imageNamed:@"大户"];
//    self.iconImageView.image = [UIImage imageNamed:@"农场"];
//    self.iconImageView.image = [UIImage imageNamed:@"合作社"];
    
    
}
@end
